package vcp.gui.panels.networkmanager;

import java.awt.BorderLayout;
import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.JLabel;

import vcp.gui.components.VCPPanel;
import vcp.gui.components.VCPScrollTable;
import com.toedter.calendar.JYearChooser;

/**
 * Quarter reports widget
 *
 */
public class PnlQuarterReports extends JPanel {

	private JComboBox comboRivon;
	private JButton btnCreate;
	private JComboBox comboReportType;
	private JComboBox comboLots;
	private JYearChooser yearChooser;
	private VCPPanel pnlTable;
	private VCPScrollTable reportsTable;
	
	/**
	 * Create the panel.
	 */
	public PnlQuarterReports() {
		setLayout(new GridLayout(2, 1));
		setBorder(new TitledBorder(null, "Quarter Reports",
				TitledBorder.LEADING, TitledBorder.TOP, null, null));

		JPanel pnlForm = new JPanel();
		pnlForm.setLayout(null);
		pnlForm.setSize(pnlForm.getParent().WIDTH, 200);

		comboRivon = new JComboBox(getRivonim());
		comboRivon.setBounds(248, 27, 99, 22);
		pnlForm.add(comboRivon);

		btnCreate = new JButton("show");
		btnCreate.setBounds(248, 99, 99, 25);
		pnlForm.add(btnCreate);

		String[] types = { "Orders", "Complaints", "Disabled parking" };

		comboReportType = new JComboBox(types);
		comboReportType.setBounds(62, 62, 99, 22);
		pnlForm.add(comboReportType);

		add(pnlForm);
		pnlForm.setLayout(null);
		
		comboLots = new JComboBox(new Object[]{1,2,3,4,5,6});
		comboLots.setBounds(62, 27, 99, 22);
		pnlForm.add(comboLots);
		
		JLabel lbllot = new JLabel("#lot");
		lbllot.setBounds(12, 30, 56, 16);
		pnlForm.add(lbllot);
		
		JLabel lblNewLabel = new JLabel("Quarter");
		lblNewLabel.setBounds(190, 30, 56, 16);
		pnlForm.add(lblNewLabel);
		
		JLabel lblYear = new JLabel("Year");
		lblYear.setBounds(190, 65, 56, 16);
		pnlForm.add(lblYear);
		
		JLabel lblType = new JLabel("Type");
		lblType.setBounds(12, 65, 56, 16);
		pnlForm.add(lblType);
		
		yearChooser = new JYearChooser();
		yearChooser.setBounds(248, 62, 99, 22);
		pnlForm.add(yearChooser);

		pnlTable = new VCPPanel();
		pnlTable.setLayout(new BorderLayout());

		add(pnlTable);
	}

	public JComboBox getComboRivon() {
		return comboRivon;
	}

	public void setComboRivon(JComboBox comboRivon) {
		this.comboRivon = comboRivon;
	}

	public JButton getBtnCreate() {
		return btnCreate;
	}

	public void setBtnCreate(JButton btnCreate) {
		this.btnCreate = btnCreate;
	}

	public JYearChooser getComboYear() {
		return yearChooser;
	}

	

	public JComboBox getComboReportType() {
		return comboReportType;
	}

	public void setComboReportType(JComboBox comboReportType) {
		this.comboReportType = comboReportType;
	}

	public JComboBox getComboLots() {
		return comboLots;
	}

	public void setComboLots(JComboBox comboLots) {
		this.comboLots = comboLots;
	}

	
	private Object[] getRivonim() {
		Object[] arr = new Object[4];
		for (int i = 0; i < 4; i++) {
			arr[i] = i + 1;
		}
		return arr;
	}
	
	public VCPPanel getPnlTable() {
		return pnlTable;
	}

	
	public VCPScrollTable getTable(String header[],int rows) {
		if(reportsTable==null){
			DefaultTableModel dtm = new DefaultTableModel(null, header) {
	    		private static final long serialVersionUID = 1L;
	    		@Override
	            public Class<?> getColumnClass(int col) {
	                return getValueAt(0, col).getClass();
	            }
	        };
			
	        reportsTable = new VCPScrollTable(rows,dtm);	

		}
		return reportsTable;
	}
}
